home *** CD-ROM | disk | FTP | other *** search
- /*
- * NameSpace abstract class
- *
- * Nested scoping name space; a kind of HashTable.
- *
- * Copyright © John Wainwright 1988
- *
- * SuperClasses :
- * HashTable
- * Instance Vars :
- * freeList
- * Class Vars :
- *
- * Methods :
- * get k - gets the closest keyed item
- * freePart - get the free namespace
- * enterScope - add a new scope nesting
- * leaveScope - exit to next level of scoping
- * Class Methods :
- *
- */
-
- #include "oic.h"
- #include "generics.h"
- #include "names.h"
-
- class NameSpace; /* the NameSpace class */
- typedef object namespace;
-
- struct NameSpace_i /* NameSpace instance structure */
- {
- namespace frees; /* free namespaces */
- };
- typedef struct NameSpace_i NameSpace_i;
-
- /* -------------------- NameSpace Instance methods ------------------- */
-
- method object
- _get(self, n, key)
- namespace self;
- register NameSpace_i *n;
- register object *key;
- {
- register object val;
-
- val = Super(self, *key);
- return (val != NULL) ? val : get(n->frees, *key);
- }
-
- method object
- _freePart(self, n)
- namespace self;
- register NameSpace_i *n;
- {
- return n->frees;
- }
-
- method object
- _enterScope(self, n)
- namespace self;
- register NameSpace_i *n;
- {
- return New(NameSpace, self);
- }
-
- /* ------------------- Init the NameSpace class ---------------------- */
-
- InitNameSpaceClass()
- {
- NameSpace = NewClass(sizeof(NameSpace_i), 0, "NameSpace", HashTable, END);
- AddMethods(NameSpace,
- getGeneric, _get,
- freePartGeneric, _freePart,
- END);
- }
-
-